package com.wzy.sxcg.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wzy.common.annotation.Log;
import com.wzy.common.core.controller.BaseController;
import com.wzy.common.core.domain.AjaxResult;
import com.wzy.common.enums.BusinessType;
import com.wzy.sxcg.domain.SxcgSxcj;
import com.wzy.sxcg.service.ISxcgSxcjService;
import com.wzy.common.utils.poi.ExcelUtil;
import com.wzy.common.core.page.TableDataInfo;

/**
 * 实习成绩Controller
 * 
 * @author wzy
 * @date 2025-10-22
 */
@RestController
@RequestMapping("/sxcg/sxcj")
public class SxcgSxcjController extends BaseController
{
    @Autowired
    private ISxcgSxcjService sxcgSxcjService;

    /**
     * 查询实习成绩列表
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:list')")
    @GetMapping("/list")
    public TableDataInfo list(SxcgSxcj sxcgSxcj)
    {
        startPage();
        List<SxcgSxcj> list = sxcgSxcjService.selectSxcgSxcjList(sxcgSxcj);
        return getDataTable(list);
    }

    /**
     * 导出实习成绩列表
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:export')")
    @Log(title = "实习成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SxcgSxcj sxcgSxcj)
    {
        List<SxcgSxcj> list = sxcgSxcjService.selectSxcgSxcjList(sxcgSxcj);
        ExcelUtil<SxcgSxcj> util = new ExcelUtil<SxcgSxcj>(SxcgSxcj.class);
        util.exportExcel(response, list, "实习成绩数据");
    }

    /**
     * 获取实习成绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:query')")
    @GetMapping(value = "/{sxcjId}")
    public AjaxResult getInfo(@PathVariable("sxcjId") Long sxcjId)
    {
        return success(sxcgSxcjService.selectSxcgSxcjBySxcjId(sxcjId));
    }

    /**
     * 新增实习成绩
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:add')")
    @Log(title = "实习成绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SxcgSxcj sxcgSxcj)
    {
        SxcgSxcj sxcgSxcjTemp = sxcgSxcjService.selectSxcgSxcjByStudentId(sxcgSxcj.getStudentId());
        if (sxcgSxcjTemp != null)
        {
            return AjaxResult.warn("该学生已录入实习成绩，请勿重复录入");
        }
        return toAjax(sxcgSxcjService.insertSxcgSxcj(sxcgSxcj));
    }

    /**
     * 修改实习成绩
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:edit')")
    @Log(title = "实习成绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SxcgSxcj sxcgSxcj)
    {
        return toAjax(sxcgSxcjService.updateSxcgSxcj(sxcgSxcj));
    }

    /**
     * 删除实习成绩
     */
    @PreAuthorize("@ss.hasPermi('sxcg:sxcj:remove')")
    @Log(title = "实习成绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sxcjIds}")
    public AjaxResult remove(@PathVariable Long[] sxcjIds)
    {
        return toAjax(sxcgSxcjService.deleteSxcgSxcjBySxcjIds(sxcjIds));
    }
}
